package org.hawk.gwt.ppc.parser.impl;

import org.hawk.gwt.ppc.parser.Token;
import org.hawk.gwt.ppc.utils.PreprocessorException;

/**
 * Filters out comment tokens (that are ignored by this parser).
 * 
 * @author alex.bereznevatiy@gmail.com
 *
 */
class TokenFilter extends AbstractTokenSource implements TokenSource {
	
	private TokenSource source;
	
	TokenFilter(TokenSource source) throws PreprocessorException {
		this.source = source;
		init();
	}

	@Override
	protected Token readNext() throws PreprocessorException {
		while (source.hasNext()) {
			Token result = source.next();
			if (!result.isComment()) {
				return result;
			}
		}
		return null;
	}
}
